package com.tencent.qf.user.controller;

import com.tencent.qf.common.aspect.annotation.ApiLog;
import com.tencent.qf.common.aspect.annotation.Signature;
import com.tencent.qf.common.pojo.ActivityPlatformHttpResult;
import com.tencent.qf.common.pojo.HttpResult;
import com.tencent.qf.user.dto.request.*;
import com.tencent.qf.user.dto.response.*;
import com.tencent.qf.user.service.ActivityPlatformService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;


/**
 * @author liuxuan
 * @time 2022/12/16 15:08
 */
@Slf4j
@RestController
@Api(tags = "用户")
public class ActivityPlatformController {

    @Autowired
    private ActivityPlatformService activityPlatformService;

    @ApiLog("任务完成事件通知")
    @PostMapping("/api/task/complete/event")
    public HttpResult taskCompleteEvent(@RequestBody TaskCompleteEventReq request) {
        return activityPlatformService.taskCompleteEvent(request);
    }

    @Signature
    @ApiLog("发放金币")
    @PostMapping("/api/activity/gold/issueGold")
    public ActivityPlatformHttpResult<Boolean> issueGold(@RequestBody IssueGoldRequest request) {
        return activityPlatformService.issueGold(request);
    }

    @Signature
    @ApiLog("通过流水号查询金币明细")
    @PostMapping("/api/activity/gold/queryGoldDetailBySerialNo")
    public ActivityPlatformHttpResult<GoldDetailResponse> queryGoldDetailBySerialNo(@RequestBody QueryGoldDetailBySerialNoRequest request) {
        return activityPlatformService.queryGoodsDetailBySerialNo(request);
    }

    @Signature
    @ApiLog("获取可用资格列表")
    @PostMapping("/api/activity/lottery/getAvailableQualificationCount")
    public ActivityPlatformHttpResult<AvailableQualificationCountDTO> getAvailableQualificationCount(@RequestBody AvailableQualificationCountRequest request) {
        return activityPlatformService.getAvailableQualificationCount(request);
    }

    @Signature
    @ApiLog("获取单单抽奖配置")
    @PostMapping("/api/orderLottery/getAwardDesc")
    public HttpResult<AwardDescResponse> getAwardDesc(@RequestBody GetAwardDescRequest request) {
        return activityPlatformService.getAwardDesc(request);
    }

    @PostMapping(value = "/api/order/queryPoints/batch")
    @ApiOperation(value = "批量查询订单应返积分信息")
    public ActivityPlatformHttpResult<List<OrderPointsResp>> queryOrderPointsBatch (@RequestBody @Valid QueryOrderPointsReq request){
        return activityPlatformService.queryOrderPointsBatch(request);
    }

    @PostMapping(value = "/api/user/taskAwardData")
    @ApiOperation(value = "查询用户任务奖励数据")
    @ApiLog(value = "查询用户任务奖励数据")
    public ActivityPlatformHttpResult<TaskAwardData> queryUserTaskAwardData (@RequestBody @Valid TaskAwardDataRequest request){
        return activityPlatformService.queryUserTaskAwardData(request);
    }

    @PostMapping(value = "/api/user/unSuccessTask")
    @ApiOperation(value = "查询用户未完成任务")
    public ActivityPlatformHttpResult<List<UserUnSucceedTask>> queryUserUnSucceedTask(@Valid @RequestBody UserUnSucceedTaskRequest request) {
        return activityPlatformService.queryUserUnSucceedTask(request);
    }


    @Signature
    @PostMapping(value = "/api/user/specialArea/info")
    @ApiOperation(value = "查询用户专区信息")
    @ApiLog(value = "查询用户专区信息")
    public ActivityPlatformHttpResult<List<SpecialAreaInfoDTO>> getSpecialAreaInfo(@Valid @RequestBody SpecialAreaInfoReq request) {
        return activityPlatformService.getSpecialAreaInfo(request);
    }
}
